﻿#region Styx Namespaces

using System;
using System.Globalization;
using System.Threading;
using GiwinMonk.Settings;
using Styx;
using Styx.Common;
using Styx.CommonBot;
using Styx.CommonBot.Routines;
using Styx.Pathing;
using Styx.WoWInternals;

    #endregion
#region System Namespaces
using System.Linq;
using System.Windows.Media;

#endregion

namespace GiwinMonk
{
    public class Routine : CombatRoutine
    {
        #region static string Values

        public static string legacyOfTheWhiteTiger = "Legacy of the White Tiger";
        public static string legacyOfTheEmperor = "Legacy of the Emperor";
        public static string ringOfPeace = "Ring of Peace";
        public static string stormEarthFire = "Storm, Earth, and Fire";
        public static string nimbleBrew = "Nimble Brew";
        public static string blackoutKick = "Blackout Kick";
        public static string energizingBrew = "Energizing Brew";
        public static string chargingOxWave = "Charging Ox Wave";
        public static string chiBurst = "Chi Burst";
        public static string cracklingJadeLightning = "Crackling Jade Lightning";
        public static string chiWave = "Chi Wave";
        public static string chiBrew = "Chi Brew";
        public static string dampenHarm = "Dampen Harm";
        public static string detox = "Detox";
        public static string disable = "Disable";
        public static string expelHarm = "Expel Harm";
        public static string fistsofFury = "Fists of Fury";
        public static string flyingSerpentKick = "Flying Serpent Kick";
        public static string fortifyingBrew = "Fortifying Brew";
        public static string grappleWeapon = "Grapple Weapon";
        public static string healingSphere = "Healing Sphere";
        public static string invokeXuen = "Invoke Xuen, the White Tiger";
        public static string jab = "Jab";
        public static string legSweep = "Leg Sweep";
        public static string lifeblood = "Lifeblood";
        public static string paralysis = "Paralysis";
        public static string quakingPalm = "Quaking Palm";
        public static string resuscitate = "Resuscitate";
        public static string risingSunKick = "Rising Sun Kick";
        public static string roll = "Roll";
        public static string rushingJadeWind = "Rushing Jade Wind";
        public static string spearHandStrike = "Spear Hand Strike";
        public static string spinningCraneKick = "Spinning Crane Kick";
        public static string spinningFireBlossom = "Spinning Fire Blossom";
        public static string tigerPalm = "Tiger Palm";
        public static string tigersLust = "Tiger's Lust";
        public static string tigereyeBrew = "Tigereye Brew";
        public static string touchofDeath = "Touch of Death";
        public static string touchofKarma = "Touch of Karma";
        public static string zenMeditation = "Zen Meditation";
        public static string zenSphere = "Zen Sphere";

        #endregion

        #region Routine Information

        public override sealed string Name
        {
            get { return "GiwinMonk"; }
        }

        public override WoWClass Class
        {
            get { return WoWClass.Monk; }
        }

        public Version Version
        {
            get { return new Version(1, 4); }
        }

        public override bool WantButton
        {
            get { return true; }
        }

        public override void OnButtonPress()
        {
            new GUI.Form1().ShowDialog();
        }

        #endregion

        #region Initialize

        public override void Initialize()
        {
            Info("Thank you for using GiwinMonk " + Version + "!");
        }

        #endregion

        #region PreCombat Buffs

        public override bool NeedPreCombatBuffs
        {
            get
            {
                return !StyxWoW.Me.Combat && !Helpers.Unit.HasMyAura(StyxWoW.Me, legacyOfTheWhiteTiger) &&
                       !StyxWoW.Me.Combat &&
                       SpellManager.CanBuff(legacyOfTheEmperor) &&
                       !Helpers.Unit.HasMyAura(StyxWoW.Me, "Blessing of Kings") &&
                       !StyxWoW.Me.Mounted && !StyxWoW.Me.IsMoving &&
                       !Helpers.Unit.HasMyAura(StyxWoW.Me, "Mark of the Wild") &&
                       !Helpers.Unit.HasMyAura(StyxWoW.Me, "Dark Intent") &&
                       !Helpers.Unit.HasMyAura(StyxWoW.Me, legacyOfTheWhiteTiger) &&
                       StyxWoW.Me.HealthPercent > MIRsettings.Instance.RestOnHealthPercent;
            }
        }

        public override void PreCombatBuff()
        {
            if (MIRsettings.Instance.LegacyOfTheEmperor)
                if (!StyxWoW.Me.Combat && !Helpers.Unit.HasMyAura(StyxWoW.Me, legacyOfTheEmperor))
                    SpellManager.Cast(legacyOfTheEmperor);
            Thread.Sleep(2000);
            if (MIRsettings.Instance.LegacyOfTheWhiteTiger)
                if (!StyxWoW.Me.Combat && !Helpers.Unit.HasMyAura(StyxWoW.Me, legacyOfTheWhiteTiger))
                    SpellManager.Cast(legacyOfTheWhiteTiger);
        }

        #endregion

        #region Pull

        public override void Pull()
        {
            if (StyxWoW.Me.CurrentTarget != null &&
                StyxWoW.Me.CurrentTarget.IsHostile)
                Approach();
        }

        #endregion

        #region Combat

        public override void Combat()
        {
            Approach();
            PriorityRotation();
        }

        #endregion

        #region Heal

        /*
        public override void Heal()
        {
            if (StyxWoW.Me.HealthPercent < 50 && !OnCooldown("Dampen Harm"))
                InstantCast("Dampen Harm");
            if (StyxWoW.Me.HealthPercent < 35 && !OnCooldown("Expel Harm"))
                InstantCast("Expel Harm");
        }
        public override void NeedHeal()
        {
                if ((StyxWoW.Me.HealthPercent < 50 && HasSpell("Dampen Harm") && !OnCooldown("Dampen Harm")) ||
                    (StyxWoW.Me.HealthPercent < 35 && HasSpell("Expel Harm") && !OnCooldown("Expel Harm")))
                    return;
        }*/

        public override bool NeedRest
        {
            get { return StyxWoW.Me.HealthPercent <= MIRsettings.Instance.RestOnHealthPercent; }
        }

        public override void Rest()
        {
            if (!StyxWoW.Me.Combat && StyxWoW.Me.HealthPercent <= 50 && StyxWoW.Me.IsAlive && !StyxWoW.Me.IsSwimming)
            {
                Styx.CommonBot.Rest.Feed();
            }

        }

        #endregion

        //#region BaseRotation
        //public void BaseRotation()
        //{
        //    using (StyxWoW.Memory.AcquireFrame())
        //    {
        //        #region Glyph

        //        if (!MIRsettings.Instance.GlyphOfTouchOfDeath &&
        //            MIRsettings.Instance.TouchOfDeath &&
        //            TouchofDeath())
        //        {
        //            InstantCast(touchofDeath);
        //        }
        //        if (MIRsettings.Instance.GlyphOfTouchOfDeath &&
        //            MIRsettings.Instance.TouchOfDeath &&
        //            GlyphofTouchofDeath())
        //        {
        //            InstantCast(touchofDeath);
        //        }

        //        #endregion

        //        #region Trinket1

        //        if (MIRsettings.Instance.Trinket1)
        //        {
        //            if (IsCCd() && Trinket1())
        //            {
        //                StyxWoW.Me.Inventory.Equipped.Trinket1.Use();
        //            }
        //        }
        //        if (MIRsettings.Instance.Trinket2)
        //        {
        //            if (!InvokeXuen() && Trinket2())
        //            {
        //                StyxWoW.Me.Inventory.Equipped.Trinket2.Use();
        //            }
        //        }

        //        #endregion

        //        #region Special Attacks

        //        if (MIRsettings.Instance.LegSweep)
        //        {
        //            if (Helpers.Unit.TealcEyeBrowRaise().GetEnumerator().MoveNext() && LegSweep())
        //            {
        //                foreach (WoWUnit unit in Helpers.Unit.TealcEyeBrowRaise().Where(unit => unit != null))
        //                {
        //                    Info("[Special]: Detected Stealth! Casting Leg Sweep");
        //                    unit.Target();
        //                    unit.Face();
        //                    InstantCast(legSweep);
        //                }
        //            }
        //        }
        //        if (MIRsettings.Instance.Lifeblood)
        //        {
        //            if (Lifeblood())
        //            {
        //                InstantCast(lifeblood);
        //            }
        //        }
        //        /*
        //            if (MIRsettings.Instance.CcOtherTarget)
        //            {
        //                if (QuakingPalm() && Helpers.Unit.CcOtherTarget().GetEnumerator().MoveNext())
        //                {
        //                    foreach (WoWUnit unit in Helpers.Unit.CcOtherTarget().Where(unit => unit != null))
        //                    {
        //                        unit.Target();
        //                        Info("[Special]: CC Other Target 'Quaking Palm'");
        //                        InstantCast(QuakingPalm);
        //                    }
        //                }
        //            }*/
        //        if (MIRsettings.Instance.CracklingJadeLightning)
        //        {
        //            if (Helpers.Unit.TealcEyeBrowRaise().GetEnumerator().MoveNext() &&
        //                CracklingJadeLightning())
        //                // Will cause problems because of 3 yrd range limit between blossoms, ismoving atm is best option because it will spread them (hopefully) around.
        //            {
        //                foreach (WoWUnit unit in Helpers.Unit.TealcEyeBrowRaise().Where(unit => unit != null))
        //                {
        //                    unit.Target();
        //                    Info("[Special]: Stealth Detected! Casting Crackling Jade Lightning");
        //                    InstantCast(cracklingJadeLightning);
        //                }
        //            }
        //        }
        //        if (MIRsettings.Instance.FistsOfFury2Targets)
        //        {
        //            if (Helpers.Unit.TargetsWithinMeleeDistanceAndMeFacingTarget()
        //                    .GetEnumerator().MoveNext() &&
        //                (FistsofFury()) && StyxWoW.Me.IsFacing(StyxWoW.Me.CurrentTarget))
        //            {
        //                WoWMovement.ClickToMove(StyxWoW.Me.CurrentTarget.Location);
        //                Info("[Special]: Casting Fists of Fury on two targets within Melee Distance");
        //                LongCast(fistsofFury);
        //                WoWMovement.MoveStop();
        //            }
        //        }
        //        if (MIRsettings.Instance.LegSweep)
        //        {
        //            if ((StyxWoW.Me.CurrentTarget.HealthPercent < 40) &&
        //                LegSweep())
        //            {
        //                InstantCast(legSweep);
        //            }
        //        }
        //        if (MIRsettings.Instance.TigersLust)
        //        {
        //            if (TigersLust())
        //            {
        //                InstantCast(tigersLust);
        //            }
        //        }
        //        if (MIRsettings.Instance.RushingJadeWind && !Interruptable())
        //        {
        //            if (RushingJadeWind() &&
        //                !FistsofFury())
        //            {
        //                InstantCast(rushingJadeWind);
        //            }
        //        }

        //        /*
        //            if (MIRsettings.Instance.DI)
        //                if (CanCast("Diffuse Magic") && StyxWoW.Me.HasAura("Frost Nova"))
        //                {
        //                    Info("[Special]: Casting Tiger's Lust against Frost Nova or Cheap Shot");
        //                    InstantCast("Diffuse Magic");
        //                }*/

        //        if (StyxWoW.Me.CurrentTarget != null &&
        //            StyxWoW.Me.CurrentTarget.Distance >= 7 &&
        //            Roll() && !Interruptable())
        //        {
        //            InstantCast(roll);
        //            Navigator.MoveTo(StyxWoW.Me.CurrentTarget.Location);
        //        }
        //        if (StyxWoW.Me.CurrentTarget != null &&
        //            StyxWoW.Me.CurrentTarget.Distance >= 10 &&
        //            FlyingSerpentKick() && !Interruptable())
        //        {
        //            InstantCast(flyingSerpentKick);
        //            Navigator.MoveTo(StyxWoW.Me.CurrentTarget.Location);
        //        }
        //        if (MIRsettings.Instance.SwitchOnHealthPercent)
        //        {
        //            if (Helpers.Unit.SwitchToTargetLowHealth().GetEnumerator().MoveNext())
        //            {
        //                foreach (
        //                    WoWPlayer unit in
        //                        Helpers.Unit.SwitchToTargetLowHealth().Where(
        //                            unit => unit != null && unit.IsAlive).Where(
        //                                unit => StyxWoW.Me.CurrentTarget.IsAlive))
        //                {
        //                    if (StyxWoW.Me.CurrentTarget != null)
        //                        Info("[Special]: Switching target from " + StyxWoW.Me.CurrentTarget.Name +
        //                                 " [" + StyxWoW.Me.CurrentTarget.HealthPercent + " ]" + " to " +
        //                                 unit.Name + " [" + unit.HealthPercent + "] ");
        //                    unit.Target();
        //                }
        //            }
        //        }
        //        if (MIRsettings.Instance.ParalysisHealingSpell)
        //        {
        //            if (Helpers.Unit.ParalysisHealingSpell().GetEnumerator().MoveNext() &&
        //                InstantCast("Paralysis") &&
        //                StyxWoW.Me.IsSafelyFacing(StyxWoW.Me.CurrentTarget) && !Interruptable())
        //            {
        //                foreach (
        //                    WoWUnit unit in Helpers.Unit.ParalysisHealingSpell().Where(unit => unit != null))
        //                {
        //                    Info("[Special]: Casting Paralysis on other target casing Healing Spell");
        //                    unit.Target();
        //                    unit.Face();
        //                    InstantCast(paralysis);
        //                    StyxWoW.Me.TargetLastTarget();
        //                }
        //            }
        //        }
        //        /*
        //            if (MIRsettings.Instance.ParalysisSameTarget)
        //            {
        //                if (Helpers.Unit.ParalysisSameTarget().GetEnumerator().MoveNext() && CanCast("Paralysis"))
        //                {
        //                    foreach (WoWUnit unit in Helpers.Unit.ParalysisSameTarget().Where(unit => unit != null))
        //                    {
        //                        Info("[Special]: Casting Paralysis on other target as target is "
        //                                      + MIRsettings.Instance.ParalysisSameTargetHealthPercent +
        //                                      "% and is party member's target");
        //                        unit.Target();
        //                        InstantCast("Paralysis");
        //                        StyxWoW.Me.TargetLastTarget();
        //                    }
        //                }
        //            }*/
        //        if (MIRsettings.Instance.ZenMeditationRanged)
        //        {
        //            if (Helpers.Unit.OtherRangedTargetsTargettingPartyMemberAndCastingHostileSpell().
        //                    GetEnumerator()
        //                    .
        //                    MoveNext() &&
        //                CanCast("Zen Meditation"))
        //            {
        //                Info("[Special Attack]: Zen Meditation to help party member taking damage");
        //                LongCast(zenMeditation);
        //                WoWMovement.MoveStop();
        //            }
        //        }
        //        //if (MIRsettings.Instance.Resuscitate)
        //        //{
        //        //    if (Helpers.Unit.ResurrectablePlayers.GetEnumerator().MoveNext() &&
        //        //        CanCast("Zen Meditation"))
        //        //    {
        //        //        Info("[Special Attack]: Zen Meditation to help party member taking damage");
        //        //        LongCast(zenMeditation);
        //        //        WoWMovement.MoveStop();
        //        //    }
        //        //}

        //        #endregion

        //        #region Standard

        //        if (MIRsettings.Instance.HealingSphere)
        //        {
        //            if (HealingSphere())
        //            {
        //                Info("[Healing] Casting Healing Sphere on Myself");
        //                SpellManager.Cast(healingSphere);
        //                SpellManager.ClickRemoteLocation(StyxWoW.Me.Location);
        //                Lua.DoString("RunMacroText('/stopspelltarget');");
        //            }
        //        }
        //        if (MIRsettings.Instance.Detox)
        //        {
        //            foreach (WoWAura aura in
        //                StyxWoW.Me.GetAllAuras().Where(
        //                    aura => aura != null && aura.Name != null && aura.Name == "Poison" && Detox()))
        //            {
        //                Info("Casting Detox on Aura Name: " + aura.Name + " Aura Flags: " + aura.Flags);
        //                InstantCast(detox);
        //            }
        //        }
        //        if (MIRsettings.Instance.LegSweep)
        //        {
        //            if (LegSweep())
        //            {
        //                InstantCast(legSweep);
        //            }
        //        }
        //        if (MIRsettings.Instance.Disable)
        //        {
        //            if (Disable())
        //            {
        //                InstantCast(disable);
        //            }
        //        }
        //        if (MIRsettings.Instance.ChiWave)
        //        {
        //            if (ChiWave())
        //            {
        //                InstantCast(chiWave);
        //            }
        //        }
        //        if (MIRsettings.Instance.FistsOfFury)
        //        {
        //            if (FistsofFury())
        //            {
        //                if (StyxWoW.Me.CurrentTarget != null)
        //                    WoWMovement.ClickToMove(StyxWoW.Me.CurrentTarget.Location);
        //                LongCast(fistsofFury);
        //                WoWMovement.MoveStop();
        //            }
        //        }
        //        if (MIRsettings.Instance.Jab)
        //        {
        //            if (Jab())
        //            {
        //                InstantCast(jab);
        //            }
        //        }
        //        if (MIRsettings.Instance.RisingSunKick)
        //        {
        //            if (RisingSunKick())
        //            {
        //                InstantCast(risingSunKick);
        //            }
        //        }
        //        if (MIRsettings.Instance.TigerPalm)
        //        {
        //            if (TigerPalm())
        //            {
        //                InstantCast(tigerPalm);
        //            }
        //        }
        //        if (!MIRsettings.Instance.GlyphOfTouchOfKarma && MIRsettings.Instance.TouchOfKarma)
        //        {
        //            if (TouchofKarma())
        //            {
        //                InstantCast(touchofKarma);
        //            }
        //        }
        //        if (MIRsettings.Instance.GlyphOfTouchOfKarma && MIRsettings.Instance.TouchOfKarma)
        //        {
        //            if (GlyphofTouchofKarma())
        //            {
        //                InstantCast(touchofKarma);
        //            }
        //        }
        //        if (MIRsettings.Instance.ExpelHarm)
        //        {
        //            if (ExpelHarm())
        //            {
        //                InstantCast(expelHarm);
        //            }
        //        }
        //        if (MIRsettings.Instance.BlackoutKick)
        //        {
        //            if (BlackoutKick())
        //            {
        //                InstantCast(blackoutKick);
        //            }
        //        }
        //        if (MIRsettings.Instance.DampenHarm)
        //        {
        //            if (DampenHarm())
        //            {
        //                InstantCast(dampenHarm);
        //            }
        //        }
        //        if (MIRsettings.Instance.SpinningCraneKick)
        //        {
        //            if (SpinningCraneKick())
        //            {
        //                LongCast(spinningCraneKick);
        //            }
        //        }
        //        if (MIRsettings.Instance.FlyingSerpentKick)
        //        {
        //            if (FlyingSerpentKick())
        //            {
        //                InstantCast(flyingSerpentKick);
        //            }
        //        }
        //        if (MIRsettings.Instance.Roll)
        //        {
        //            if (Roll())
        //            {
        //                InstantCast(roll);
        //            }
        //        }
        //        if (MIRsettings.Instance.GrappleWeapon)
        //        {
        //            if (GrappleWeapon())
        //            {
        //                InstantCast(grappleWeapon);
        //            }
        //        }

        //        #endregion

        //        #region Interrupt

        //        if (MIRsettings.Instance.Paralysis)
        //        {
        //            if (Paralysis())
        //            {
        //                InstantCast(paralysis);
        //            }
        //        }
        //        if (MIRsettings.Instance.SpearHandStrike)
        //        {
        //            if (SpearHandStrike())
        //            {
        //                InstantCast(spearHandStrike);
        //            }
        //        }

        //        #endregion

        //        #region Brew

        //        if (MIRsettings.Instance.NimbleBrew)
        //        {
        //            if (NimbleBrew())
        //            {
        //                InstantCast(nimbleBrew);
        //            }
        //        }
        //        if (MIRsettings.Instance.RingOfPeace)
        //        {
        //            if (RingOfPeace())
        //            {
        //                InstantCast(ringOfPeace);
        //            }
        //        }
        //        if (MIRsettings.Instance.StormEarthFire)
        //        {
        //            if (StormEarthFire())
        //            {
        //                InstantCast(stormEarthFire);
        //            }
        //        }
        //        if (MIRsettings.Instance.EnergizingBrew)
        //        {
        //            if (EnergizingBrew())
        //            {
        //                InstantCast(energizingBrew);
        //            }
        //        }
        //        if (MIRsettings.Instance.QuakingPalm)
        //        {
        //            if (QuakingPalm())
        //            {
        //                InstantCast(quakingPalm);
        //            }
        //        }
        //        if (MIRsettings.Instance.FortifyingBrew)
        //        {
        //            if (FortifyingBrew())
        //            {
        //                InstantCast(fortifyingBrew);
        //            }
        //        }
        //        if (MIRsettings.Instance.TigereyeBrew)
        //        {
        //            if (Helpers.Unit.HasMyAura(StyxWoW.Me, tigereyeBrew, 10) && TigereyeBrew())
        //            {
        //                Info("[Special]: " + tigereyeBrew + " at 10 stacks.. consuming..");
        //                InstantCast(tigereyeBrew);
        //            }
        //        }
        //        if (MIRsettings.Instance.ChiBrew)
        //        {
        //            if (ChiBrew())
        //            {
        //                InstantCast(chiBrew);
        //            }
        //        }
        //        if (StyxWoW.Me.CurrentTarget != null &&
        //            (StyxWoW.Me.CurrentTarget.IsBoss &&
        //             StyxWoW.Me.HasAura("Death Note")))
        //        {
        //            InstantCast(touchofDeath);
        //        }

        //        #endregion

        //        #region Talent

        //        if (MIRsettings.Instance.InvokeXuen)
        //        {
        //            if (InvokeXuen())
        //            {
        //                InstantCast(invokeXuen);
        //            }
        //        }
        //        if (MIRsettings.Instance.ChiBurst)
        //        {
        //            if (ChiBurst())
        //            {
        //                LongCast(chiBurst);
        //            }
        //        }
        //        if (MIRsettings.Instance.SpinningFireBlossom)
        //        {
        //            if (SpinningFireBlossom())
        //            {
        //                InstantCast(spinningFireBlossom);
        //            }
        //        }
        //        if (MIRsettings.Instance.ChargingOxWave)
        //        {
        //            if (ChargingOxWave())
        //            {
        //                InstantCast(chargingOxWave);
        //            }
        //        }
        //        if (MIRsettings.Instance.CracklingJadeLightning)
        //        {
        //            if (CracklingJadeLightning())
        //            {
        //                InstantCast(cracklingJadeLightning);
        //            }
        //        }
        //        if (MIRsettings.Instance.ZenMeditation)
        //        {
        //            if (ZenMeditation())
        //            {
        //                LongCast(zenMeditation);
        //                WoWMovement.MoveStop();
        //                // one more to block the movement after a spell cast, as channel delay isnt picked up
        //            }
        //        }

        //        #endregion
        //    }
        //}
        //#endregion

        #region PriorityRotation

        public void PriorityRotation()
        {
            using (StyxWoW.Memory.AcquireFrame())
            {
                #region Glyph

                if (TouchofDeath())
                {
                    InstantCast(touchofDeath);
                }

                #endregion

                #region Special Attacks (Highest Priority)


                if (Lifeblood())
                {
                    InstantCast(lifeblood);
                }
                if (DiffuseMagic())
                {
                    InstantCast("Diffuse Magic");
                }
                if (LegSweep())
                {
                    InstantCast(legSweep);
                }

                if (TigersLust())
                {
                    InstantCast(tigersLust);
                }
                if (RushingJadeWind() &&
                    !FistsofFury())
                {
                    InstantCast(rushingJadeWind);
                }


                //if (StyxWoW.Me.CurrentTarget != null &&
                //    StyxWoW.Me.CurrentTarget.Distance >= 7 &&
                //    Roll() && !Interruptable())
                //{
                //    InstantCast(roll);
                //    Navigator.MoveTo(StyxWoW.Me.CurrentTarget.Location);
                //}
                //if (StyxWoW.Me.CurrentTarget != null &&
                //    StyxWoW.Me.CurrentTarget.Distance >= 10 &&
                //    FlyingSerpentKick() && !Interruptable())
                //{
                //    InstantCast(flyingSerpentKick);
                //    Navigator.MoveTo(StyxWoW.Me.CurrentTarget.Location);
                //}
                if (MIRsettings.Instance.ZenMeditationRanged)
                {
                    if (Helpers.Unit.OtherRangedTargetsTargettingPartyMemberAndCastingHostileSpell().
                            GetEnumerator().MoveNext() &&
                        CanCast("Zen Meditation"))
                    {
                        Info("[Special Attack]: Zen Meditation to help party member taking damage");
                        LongCast(zenMeditation);
                        WoWMovement.MoveStop();
                    }
                }

                #endregion

                #region Trinket1

                if (IsCCd() && Trinket1())
                {
                    StyxWoW.Me.Inventory.Equipped.Trinket1.Use();
                }
                if (IsCCd() && NimbleBrew())
                {
                    InstantCast(nimbleBrew);
                }
                //if (!InvokeXuen() && Trinket2())
                //{
                //    StyxWoW.Me.Inventory.Equipped.Trinket2.Use();
                //}


                #endregion

                #region Standard

                if (HealingSphere())
                {
                    Info("[Healing] Casting Healing Sphere on Myself");
                    SpellManager.Cast(healingSphere);
                    SpellManager.ClickRemoteLocation(StyxWoW.Me.Location);
                    Lua.DoString("RunMacroText('/stopspelltarget');");
                }
                if (Detox())
                {
                    InstantCast(detox);
                }
                if (LegSweep())
                {
                    InstantCast(legSweep);
                }
                if (Disable())
                {
                    InstantCast(disable);

                }
                if (ChiWave())
                {
                    InstantCast(chiWave);
                }
                if (FistsofFury())
                {
                    WoWMovement.MoveStop();
                    LongCast(fistsofFury);
                    WoWMovement.MoveStop();
                }
                if (Jab())
                {
                    InstantCast(jab);
                }
                if (RisingSunKick())
                {
                    InstantCast(risingSunKick);
                }
                if (TigerPalm() && !Interruptable())
                {
                    InstantCast(tigerPalm);
                }
                if (TouchofKarma())
                {
                    InstantCast(touchofKarma);
                }
                if (ExpelHarm())
                {
                    InstantCast(expelHarm);
                }
                if (BlackoutKick())
                {
                    InstantCast(blackoutKick);
                }
                if (DampenHarm())
                {
                    InstantCast(dampenHarm);
                }
                if (SpinningCraneKick())
                {
                    LongCast(spinningCraneKick);
                }
                if (FlyingSerpentKick())
                {
                    InstantCast(flyingSerpentKick);
                }
                if (Roll())
                {
                    InstantCast(roll);
                }
                if (GrappleWeapon() && SpellManager.Spells[ringOfPeace].Cooldown)
                {
                    InstantCast(grappleWeapon);
                }

                #endregion

                #region Interrupt

                if (Paralysis())
                {
                    InstantCast(paralysis);
                }
                if (SpearHandStrike())
                {
                    InstantCast(spearHandStrike);
                }

                #endregion

                #region Brew

                if (EnergizingBrew())
                {
                    InstantCast(energizingBrew);
                }
                if (QuakingPalm())
                {
                    InstantCast(quakingPalm);
                }
                if (NimbleBrew())
                {
                    InstantCast(nimbleBrew);
                }
                if (RingOfPeace() && !GrappleWeapon())
                {
                    InstantCast(ringOfPeace);
                }
                if (StormEarthFire())
                {
                    InstantCast(stormEarthFire);
                }
                if (FortifyingBrew())
                {
                    InstantCast(fortifyingBrew);
                }
                if (Helpers.Unit.HasMyAura(StyxWoW.Me, tigereyeBrew, 10) && TigereyeBrew())
                {
                    Info("[Special]: " + tigereyeBrew + " at 10 stacks.. consuming..");
                    InstantCast(tigereyeBrew);
                }
                if (ChiBrew())
                {
                    InstantCast(chiBrew);
                }

                #endregion

                #region Talent

                if (InvokeXuen())
                {
                    InstantCast(invokeXuen);
                }
                if (ChiBurst() && !Interruptable())
                {
                    LongCast(chiBurst);
                }
                if (SpinningFireBlossom() && !Interruptable())
                {
                    InstantCast(spinningFireBlossom);
                }
                if (ChargingOxWave() && !Interruptable())
                {
                    InstantCast(chargingOxWave);
                }
                if (CracklingJadeLightning() && !Interruptable())
                {
                    InstantCast(cracklingJadeLightning);
                }
                if (ZenMeditation())
                {
                    LongCast(zenMeditation);
                    WoWMovement.MoveStop();
                    // one more to block the movement after a spell cast, as channel delay isnt picked up
                }

                #endregion
            }
        }

        #endregion

        #region Trinket

        public bool Trinket1()
        {
            return (StyxWoW.Me.Inventory.Equipped.Trinket1.CooldownTimeLeft == TimeSpan.Zero);
        }

        public bool Trinket2()
        {
            return (StyxWoW.Me.Inventory.Equipped.Trinket2.CooldownTimeLeft == TimeSpan.Zero);
        }

        #endregion

        #region Spells

        public bool CanCast(string spellName)
        {
            return SpellManager.HasSpell(spellName) &&
                   !SpellManager.Spells[spellName].Cooldown &&
                   !SpellManager.GlobalCooldown &&
                   SpellManager.Spells[spellName].BaseCooldown == 0 &&
                   !StyxWoW.Me.IsChanneling &&
                   SpellManager.CanCast(spellName);
        }

        public bool BlackoutKick()
        {
            return (MIRsettings.Instance.BlackoutKick) &&
                   (StyxWoW.Me.CurrentTarget != null) &&
                   (StyxWoW.Me.IsSafelyFacing(StyxWoW.Me.CurrentTarget)) &&
                   (StyxWoW.Me.CurrentTarget.IsWithinMeleeRange) &&
                   (StyxWoW.Me.CurrentChi >= 2 ||
                    Helpers.Unit.HasMyAura(StyxWoW.Me, "Combo Breaker: Blackout Kick")) &&
                   CanCast("Blackout Kick");
        }

        public bool ChargingOxWave()
        {
            return (MIRsettings.Instance.ChargingOxWave) &&
                   (StyxWoW.Me.CurrentTarget != null) &&
                   (StyxWoW.Me.CurrentTarget.IsCasting) &&
                   (StyxWoW.Me.CurrentTarget.Distance < 30) &&
                   (StyxWoW.Me.IsFacing(StyxWoW.Me.CurrentTarget)) &&
                   CanCast("Charging Ox Wave");
        }

        public bool ChiBurst()
        {
            return //(MIRsettings.Instance.ChiBurst) && 
                (StyxWoW.Me.CurrentTarget != null) &&
                StyxWoW.Me.CurrentTarget.Distance <= 40 &&
                !StyxWoW.Me.CurrentTarget.IsWithinMeleeRange &&
                StyxWoW.Me.IsSafelyFacing(StyxWoW.Me.CurrentTarget) &&
                CanCast("Chi Burst");
        }

        public bool ChiWave()
        {
            return //(MIRsettings.Instance.ChiBurst) && 
                (StyxWoW.Me.CurrentTarget != null) &&
                StyxWoW.Me.IsFacing(StyxWoW.Me.CurrentTarget) &&
                StyxWoW.Me.HealthPercent < 80 &&
                CanCast("Chi Wave");
        }

        public bool CracklingJadeLightning()
        {
            return (MIRsettings.Instance.CracklingJadeLightning) &&
                   (StyxWoW.Me.CurrentTarget != null) &&
                   (StyxWoW.Me.CurrentTarget.Distance <= 40) &&
                   (StyxWoW.Me.CurrentTarget.Distance > 10) &&
                   (StyxWoW.Me.CurrentTarget.Class == WoWClass.DeathKnight ||
                    StyxWoW.Me.CurrentTarget.Class == WoWClass.Rogue ||
                    StyxWoW.Me.CurrentTarget.Class == WoWClass.Warrior) &&
                   CanCast("Crackling Jade Lightning");
        }

        public bool DampenHarm()
        {
            return (MIRsettings.Instance.DampenHarm) &&
                   (StyxWoW.Me.CurrentTarget != null) &&
                   (StyxWoW.Me.HealthPercent < 75) &&
                   (StyxWoW.Me.Stunned) &&
                   CanCast("Dampen Harm");
        }

        public bool DiffuseMagic()
        {
            return MIRsettings.Instance.DiffuseMagic &&
                (StyxWoW.Me.CurrentTarget != null) &&
                   (Helpers.Unit.HasAuraWithMechanic(StyxWoW.Me, WoWSpellMechanic.Frozen) ||
                   Helpers.Unit.HasAnyAura(StyxWoW.Me, "Frozen Orb") ||
                   StyxWoW.Me.Debuffs.Count > 3) &&
                   CanCast("Diffuse Magic");
        }

        public bool Detox()
        {
            return StyxWoW.Me.GetAllAuras().Any(aura => aura != null && aura.Name != null && aura.Name == "Poison") &&
                   CanCast(detox);
        }

        public bool Disable()
        {
            return (MIRsettings.Instance.Disable) &&
                   (StyxWoW.Me.CurrentTarget != null) &&
                   (StyxWoW.Me.CurrentTarget.IsPlayer) &&
                   StyxWoW.Me.IsFacing(StyxWoW.Me.CurrentTarget) &&
                   (!StyxWoW.Me.CurrentTarget.HasAura("Disable") &&
                    StyxWoW.Me.CurrentTarget.IsWithinMeleeRange &&
                    CanCast("Disable"));
        }

        public bool ExpelHarm()
        {
            return (MIRsettings.Instance.ExpelHarm) &&
                   (StyxWoW.Me.EnergyPercent >= 40) &&
                   (StyxWoW.Me.HealthPercent < 95) &&
                   (StyxWoW.Me.CurrentChi < 2) &&
                   CanCast("Expel Harm");
        }

        public bool FistsofFury()
        {
            return (MIRsettings.Instance.FistsOfFury) &&
                   (StyxWoW.Me.CurrentTarget != null) &&
                   (StyxWoW.Me.CurrentChi >= 3) &&
                   (StyxWoW.Me.CurrentTarget.Distance < 7) &&
                   (StyxWoW.Me.IsFacing(StyxWoW.Me.CurrentTarget)) &&
                   CanCast("Fists of Fury");
        }

        public bool FistsofFuryEmptyChi()
        {
            return (MIRsettings.Instance.FistsOfFury) &&
                   (StyxWoW.Me.CurrentTarget != null) &&
                   StyxWoW.Me.CurrentTarget.IsWithinMeleeRange &&
                   CanCast("Fists of Fury");
        }

        public bool FlyingSerpentKick()
        {
            return (MIRsettings.Instance.FlyingSerpentKick) &&
                   (StyxWoW.Me.CurrentTarget != null) &&
                   !StyxWoW.Me.Stunned &&
                   StyxWoW.Me.IsFacing(StyxWoW.Me.CurrentTarget) &&
                   StyxWoW.Me.CurrentTarget.Distance > 14 &&
                   CanCast("Flying Serpent Kick");
        }

        public bool FoFlsrscRotation()
        {
            return //(MIRsettings.Instance.BlackoutKick) &&
                FistsofFury() &&
                LegSweep() && RisingSunKick();
        }

        public bool GrappleWeapon()
        {
            return (MIRsettings.Instance.GrappleWeapon) &&
                   (StyxWoW.Me.CurrentTarget != null) &&
                   (StyxWoW.Me.IsSafelyFacing(StyxWoW.Me.CurrentTarget)) &&
                   StyxWoW.Me.CurrentTarget.Distance <= 40 &&
                   StyxWoW.Me.CurrentTarget.IsPlayer &&
                   (StyxWoW.Me.CurrentTarget.Class == WoWClass.DeathKnight ||
                    StyxWoW.Me.CurrentTarget.Class == WoWClass.Warrior ||
                    StyxWoW.Me.CurrentTarget.Class == WoWClass.Rogue) &&
                   CanCast("Grapple Weapon");
        }

        public bool HealingSphere()
        {
            return (MIRsettings.Instance.HealingSphere) &&
                   (StyxWoW.Me.HealthPercent < 80 &&
                    !StyxWoW.Me.Stunned) &&
                   (StyxWoW.Me.EnergyPercent >= 60) &&
                   CanCast("Healing Sphere");
        }

        public bool InvokeXuen()
        {
            return (MIRsettings.Instance.InvokeXuen) &&
                   (StyxWoW.Me.CurrentTarget != null) &&
                   StyxWoW.Me.CurrentTarget.InLineOfSight &&
                   CanCast("Invoke Xuen, the White Tiger");
        }

        public bool Jab()
        {
            return (MIRsettings.Instance.Jab) &&
                   (StyxWoW.Me.CurrentTarget != null) &&
                   StyxWoW.Me.IsSafelyFacing(StyxWoW.Me.CurrentTarget) &&
                   StyxWoW.Me.CurrentTarget.IsWithinMeleeRange &&
                   StyxWoW.Me.CurrentChi != StyxWoW.Me.MaxChi &&
                   StyxWoW.Me.EnergyPercent >= 40 &&
                   !ExpelHarm() &&
                   CanCast("Jab");
        }

        public bool LegSweep()
        {
            return (MIRsettings.Instance.LegSweep) &&
                   (StyxWoW.Me.CurrentTarget != null) &&
                   (StyxWoW.Me.IsSafelyFacing(StyxWoW.Me.CurrentTarget)) &&
                   (StyxWoW.Me.CurrentTarget.IsWithinMeleeRange) &&
                   (StyxWoW.Me.CurrentTarget.CanInterruptCurrentSpellCast ||
                    StyxWoW.Me.CurrentTarget.IsCastingHealingSpell ||
                    Helpers.Unit.Adds.Count > 0) &&
                   StyxWoW.Me.HealthPercent < 40 &&
                   CanCast("Leg Sweep");
        }

        public bool Lifeblood()
        {
            return (MIRsettings.Instance.Lifeblood) &&
                   (StyxWoW.Me.CurrentTarget != null) &&
                   !SpellManager.Spells["Lifeblood"].Cooldown;
        }

        public bool Paralysis()
        {
            return (MIRsettings.Instance.Paralysis) &&
                   (StyxWoW.Me.CurrentTarget != null) &&
                   (StyxWoW.Me.CurrentTarget.Distance <= 20) &&
                   (StyxWoW.Me.CurrentTarget.IsCasting ||
                    StyxWoW.Me.CurrentTarget.IsCastingHealingSpell) &&
                   (StyxWoW.Me.CurrentTarget.IsPlayer) &&
                   CanCast("Paralysis");
        }

        public bool PathOfBlossoms()
        {
            return (MIRsettings.Instance.PathOfBlossoms) &&
                   (StyxWoW.Me.CurrentTarget != null) &&
                   !StyxWoW.Me.CurrentTarget.IsMoving &&
                   StyxWoW.Me.CurrentTarget.CurrentTarget != null &&
                   StyxWoW.Me.CurrentTarget.CurrentTarget.IsMe &&
                   StyxWoW.Me.EnergyPercent >= 30 &&
                   StyxWoW.Me.CurrentTarget.IsWithinMeleeRange &&
                   CanCast("Path of Blossoms");
        }

        public bool QuakingPalm()
        {
            return (MIRsettings.Instance.QuakingPalm) &&
                   (StyxWoW.Me.CurrentTarget != null) &&
                   (StyxWoW.Me.CurrentTarget.IsWithinMeleeRange) &&
                   (StyxWoW.Me.CurrentTarget.CanInterruptCurrentSpellCast ||
                    StyxWoW.Me.CurrentTarget.IsCastingHealingSpell) &&
                   CanCast("Quaking Palm");
        }

        public bool Resuscitate()
        {
            return (MIRsettings.Instance.Resuscitate) &&
                   !StyxWoW.Me.Combat &&
                   StyxWoW.Me.EnergyPercent >= 50 &&
                   CanCast("Resuscitate");
        }

        public bool RisingSunKick()
        {
            return (MIRsettings.Instance.RisingSunKick) &&
                   (StyxWoW.Me.CurrentTarget != null) &&
                   StyxWoW.Me.IsSafelyFacing(StyxWoW.Me.CurrentTarget) &&
                   StyxWoW.Me.CurrentTarget.IsWithinMeleeRange &&
                   StyxWoW.Me.CurrentChi >= 2 &&
                   CanCast("Rising Sun Kick");
        }

        public bool Roll()
        {
            return (MIRsettings.Instance.Roll) &&
                   (StyxWoW.Me.CurrentTarget != null) &&
                   (StyxWoW.Me.IsFacing(StyxWoW.Me.CurrentTarget)) &&
                   StyxWoW.Me.CurrentTarget.Distance > 11 &&
                   CanCast("Roll");
        }

        public bool RingOfPeace()
        {
            // Useful if being attacked by two melee in Arena
            return MIRsettings.Instance.RingOfPeace &&
                   (StyxWoW.Me.CurrentTarget != null &&
                    StyxWoW.Me.CurrentTarget.IsWithinMeleeRange) &&
                   (StyxWoW.Me.EnergyPercent > 10) &&
                   CanCast("Ring of Peace");

        }

        public bool NimbleBrew()
        {
            return MIRsettings.Instance.NimbleBrew &&
                   StyxWoW.Me.CurrentTarget != null &&
                   Helpers.Unit.HasAuraWithMechanic(StyxWoW.Me, WoWSpellMechanic.Stunned) &&
                   CanCast("Nimble Brew");
        }

        public bool StormEarthFire()
        {
            return MIRsettings.Instance.StormEarthFire &&
                   StyxWoW.Me.CurrentTarget != null &&
                   StyxWoW.Me.CurrentTarget.HealthPercent < 50 &&
                   !StyxWoW.Me.HasAura("Storm, Earth, and Fire") &&
                   CanCast("Storm, Earth, and Fire");
        }

        public bool RskfoFlsehbk()
        {
            return //(MIRsettings.Instance.BlackoutKick) &&
                RisingSunKick() && FistsofFury() && LegSweep() && ExpelHarm() && BlackoutKick();
        }

        public bool RushingJadeWind()
        {
            return (MIRsettings.Instance.BlackoutKick) &&
                   (StyxWoW.Me.CurrentTarget != null) &&
                   (StyxWoW.Me.IsFacing(StyxWoW.Me.CurrentTarget)) &&
                   (StyxWoW.Me.CurrentTarget.Distance < 30) &&
                   (StyxWoW.Me.CurrentTarget.InLineOfSight) &&
                   (StyxWoW.Me.CurrentChi >= 2) &&
                   CanCast("Rushing Jade Wind");
        }

        public bool SpearHandStrike()
        {
            return (MIRsettings.Instance.SpearHandStrike) &&
                   (StyxWoW.Me.CurrentTarget != null) &&
                   (StyxWoW.Me.EnergyPercent >= 10) &&
                   (StyxWoW.Me.CurrentTarget.IsWithinMeleeRange) &&
                   (StyxWoW.Me.CurrentTarget.IsCastingHealingSpell ||
                    StyxWoW.Me.CurrentTarget.IsCasting) &&
                   CanCast("Spear Hand Strike");
        }

        public bool SpinningCraneKick()
        {
            return (MIRsettings.Instance.SpinningCraneKick) &&
                   (StyxWoW.Me.CurrentTarget != null) &&
                   StyxWoW.Me.EnergyPercent >= 30 &&
                   StyxWoW.Me.CurrentTarget.Distance <= 8 &&
                   CanCast("Spinning Crane Kick") &&
                   Helpers.Unit.Adds.Count > 1;
        }

        public bool SpinningFireBlossom()
        {
            return (MIRsettings.Instance.SpinningFireBlossom) &&
                   (StyxWoW.Me.CurrentTarget != null) &&
                   (StyxWoW.Me.CurrentChi >= 1) &&
                   (StyxWoW.Me.IsFacing(StyxWoW.Me.CurrentTarget.Location)) &&
                   (StyxWoW.Me.CurrentTarget.Distance <= 50) &&
                   (StyxWoW.Me.CurrentTarget.HealthPercent < 20 ||
                    !StyxWoW.Me.IsCasting ||
                    !StyxWoW.Me.IsChanneling) &&
                   (!StyxWoW.Me.CurrentTarget.IsWithinMeleeRange) &&
                   CanCast("Spinning Fire Blossom");
        }

        public bool TigerPalm()
        {
            return (MIRsettings.Instance.TigerPalm) &&
                   (StyxWoW.Me.CurrentTarget != null) &&
                   (StyxWoW.Me.IsSafelyFacing(StyxWoW.Me.CurrentTarget)) &&
                   (StyxWoW.Me.CurrentTarget.IsWithinMeleeRange) &&
                   (Helpers.Unit.HasAnyAura(StyxWoW.Me, "Combo Breaker: Tiger Palm") ||
                    StyxWoW.Me.CurrentChi >= 1) &&
                   (!Helpers.Unit.HasMyAura(StyxWoW.Me, "Tiger Power") ||
                    StyxWoW.Me.ActiveAuras["Tiger Power"].TimeLeft < TimeSpan.FromSeconds(8)) &&
                   CanCast("Tiger Palm");
        }

        public bool TigersLust()
        {
            return (MIRsettings.Instance.TigersLust) &&
                   (StyxWoW.Me.CurrentTarget != null) &&
                   (Helpers.Unit.HasAuraWithMechanic(StyxWoW.Me, WoWSpellMechanic.Rooted) ||
                    Helpers.Unit.HasAuraWithMechanic(StyxWoW.Me, WoWSpellMechanic.Slowed) ||
                    Helpers.Unit.HasAuraWithMechanic(StyxWoW.Me, WoWSpellMechanic.Gripped) ||
                    Helpers.Unit.HasAuraWithMechanic(StyxWoW.Me, WoWSpellMechanic.Dazed)) &&
                   CanCast("Tiger's Lust");
        }

        public bool TouchofDeath()
        {
            return MIRsettings.Instance.TouchOfDeath &&
                (StyxWoW.Me.CurrentTarget != null) &&
                   StyxWoW.Me.CurrentTarget.IsWithinMeleeRange &&
                   StyxWoW.Me.CurrentTarget.HealthPercent <= 10 &&
                   StyxWoW.Me.IsSafelyFacing(StyxWoW.Me.CurrentTarget) &&
                   CanCast("Touch of Death");
        }

        public bool TouchofKarma()
        {
            return (MIRsettings.Instance.TouchOfKarma) &&
                   (StyxWoW.Me.CurrentTarget != null) &&
                   (StyxWoW.Me.IsSafelyFacing(StyxWoW.Me.CurrentTarget)) &&
                   (StyxWoW.Me.CurrentTarget.Distance <= 20) &&
                   (StyxWoW.Me.CurrentTarget.CurrentTarget != null) &&
                   (StyxWoW.Me.CurrentTarget.CurrentTarget.IsMe) &&
                   CanCast("Touch of Karma");
        }

        public bool ZenMeditation()
        {
            return (MIRsettings.Instance.ZenMeditation) &&
                   (StyxWoW.Me.CurrentTarget != null) &&
                   (StyxWoW.Me.CurrentTarget.Class == WoWClass.Mage ||
                    StyxWoW.Me.CurrentTarget.Class == WoWClass.Warlock) &&
                   StyxWoW.Me.CurrentTarget.CurrentTarget != null &&
                   StyxWoW.Me.CurrentTarget.CurrentTarget.IsMe &&
                   (StyxWoW.Me.CurrentTarget.Distance <= 30) &&
                   CanCast("Zen Meditation");
        }

        public bool ZenSphere()
        {
            return //(MIRsettings.Instance.ZenSphere) && 
                (StyxWoW.Me.CurrentTarget != null) &&
                StyxWoW.Me.CurrentChi >= 2 &&
                StyxWoW.Me.HealthPercent < 70 &&
                CanCast("Zen Sphere");
        }

        #endregion

        #region Cast

        public bool Buff(string spellName)
        {
            if (SpellManager.CanCast(spellName) &&
                !SpellManager.Spells[spellName].Cooldown &&
                !StyxWoW.Me.IsCasting && !StyxWoW.Me.IsChanneling &&
                !IsCCd())
                StyxWoW.Me.ClearTarget();
            StyxWoW.SleepForLagDuration();
            SpellManager.Cast(spellName);
            Info("Buff: " + spellName +
                 " (Energy: " + StyxWoW.Me.CurrentEnergy +
                 ", Chi: " + StyxWoW.Me.CurrentChi.ToString(CultureInfo.InvariantCulture) + ")");
            return true;
        }

        public bool InstantCast(string spellName)
        {
            if (StyxWoW.Me.CurrentTarget != null &&
                !StyxWoW.Me.IsCasting &&
                !StyxWoW.Me.IsChanneling && SpellManager.HasSpell(spellName) &&
                !SpellManager.GlobalCooldown)
                SpellManager.Cast(spellName);
            StyxWoW.SleepForLagDuration();

            Info("InstantCast: " + spellName +
                 " (Energy: " + StyxWoW.Me.CurrentEnergy +
                 ", Chi: " + StyxWoW.Me.CurrentChi.ToString(CultureInfo.InvariantCulture) + ")");
            return true;
        }

        public bool LongCast(string spellName)
        {
            if (StyxWoW.Me.CurrentTarget != null &&
                SpellManager.HasSpell(spellName) &&
                SpellManager.CanCast(SpellManager.Spells[spellName], StyxWoW.Me.CurrentTarget, false, false, false) &&
                !StyxWoW.Me.IsCasting &&
                !StyxWoW.Me.IsChanneling &&
                StyxWoW.Me.IsSafelyFacing(StyxWoW.Me.CurrentTarget) &&
                !StyxWoW.Me.IsMoving &&
                !SpellManager.GlobalCooldown)
                SpellManager.Cast(spellName);
            StyxWoW.SleepForLagDuration();
            Info("LongCast: " + spellName + " (Energy: " + StyxWoW.Me.CurrentEnergy + ", Chi: " +
                 StyxWoW.Me.CurrentChi.ToString(CultureInfo.InvariantCulture) + ")");
            return true;
        }

        #endregion

        #region Brew

        public bool EnergizingBrew()
        {
            return StyxWoW.Me.EnergyPercent < 70 &&
                   !SpellManager.Spells["Energizing Brew"].Cooldown && !StyxWoW.Me.IsChanneling;
        }

        public bool FortifyingBrew()
        {
            return (StyxWoW.Me.HealthPercent < 85 || Helpers.Unit.AddsOnMe().Count > 0) &&
                   (!SpellManager.Spells["Fortifying Brew"].Cooldown && !StyxWoW.Me.IsChanneling);
        }

        public bool ChiBrew()
        {
            return StyxWoW.Me.CurrentChi == 0 &&
                   StyxWoW.Me.CurrentTarget.HealthPercent < 70 &&
                   SpellManager.HasSpell("Chi Brew") &&
                   !SpellManager.Spells["Chi Brew"].Cooldown && !StyxWoW.Me.IsChanneling;
        }

        public bool TigereyeBrew()
        {
            return Helpers.Unit.HasMyAura(StyxWoW.Me, "Tigereye Brew", 10) &&
                   !SpellManager.Spells["Tigereye Brew"].Cooldown && !StyxWoW.Me.IsChanneling;
        }

        #endregion

        #region Log

        public void Warning(string msg)
        {
            Styx.Common.Logging.Write(Color.FromRgb(255, 0, 0), string.Format("[{0}][{1}]: {2}", Name, Version, msg));
        }

        public void Info(string msg)
        {
            Styx.Common.Logging.Write(Color.FromRgb(255, 255, 204), string.Format("[{0}][{1}]: {2}", Name, Version, msg));
        }

        #endregion

        #region MajorGlyph


        #endregion

        #region Check

        public void Approach()
        {
            if (StyxWoW.Me.CurrentTarget != null &&
                Navigator.CanNavigateFully(StyxWoW.Me.Location, StyxWoW.Me.CurrentTarget.Location) &&
                !StyxWoW.Me.IsCasting &&
                !StyxWoW.Me.IsChanneling)
            {
                Info("Inside new Navigator");
                Navigator.MoveTo(StyxWoW.Me.CurrentTarget.Location);
            }
            else if (StyxWoW.Me.CurrentTarget != null &&
                !Navigator.CanNavigateFully(StyxWoW.Me.Location, StyxWoW.Me.CurrentTarget.Location) &&
                !StyxWoW.Me.IsIndoors &&
                !StyxWoW.Me.IsSwimming &&
                !StyxWoW.Me.IsChanneling &&
                !StyxWoW.Me.CurrentTarget.IsWithinMeleeRange)
            {
                Info("Moving to Current Target");
                WoWMovement.ClickToMove(StyxWoW.Me.CurrentTarget.Location);
            }

            if (StyxWoW.Me.CurrentTarget != null &&
                StyxWoW.Me.CurrentTarget.ZDiff < 4 &&
                !StyxWoW.Me.IsIndoors &&
                !StyxWoW.Me.IsSwimming &&
                !StyxWoW.Me.IsFacing(StyxWoW.Me.CurrentTarget) &&
                !StyxWoW.Me.IsChanneling)
            {
                Info("Inside Facing");
                WoWMovement.ClickToMove(StyxWoW.Me.CurrentTarget.Location);
            }

            if (StyxWoW.Me.CurrentTarget != null &&
                !StyxWoW.Me.IsAutoAttacking &&
                StyxWoW.Me.IsSafelyFacing(StyxWoW.Me.CurrentTarget) &&
                StyxWoW.Me.CurrentTarget.IsWithinMeleeRange &&
                !StyxWoW.Me.IsChanneling)
            {
                Info("Inside ToggerAttack");
                StyxWoW.Me.ToggleAttack();
            }


            if (StyxWoW.Me.CurrentTarget != null &&
                !StyxWoW.Me.IsChanneling &&
                StyxWoW.Me.CurrentTarget.Distance < 2.5 &&
                !StyxWoW.Me.CurrentTarget.IsMoving &&
                StyxWoW.Me.IsMoving)
            {
                Info("Inside MoveStop");
                WoWMovement.MoveStop(WoWMovement.MovementDirection.None);
            }
            if (StyxWoW.Me.CurrentTarget != null &&
                StyxWoW.Me.IsChanneling)
            {
                WoWMovement.ConstantFace(StyxWoW.Me.CurrentTarget.Guid);
            }
        }

        public bool CanInterrupt()
        {
            if ((StyxWoW.Me.CurrentTarget.IsCasting && SpellManager.CanCast(107079)) ||
                ((StyxWoW.Me.CurrentTarget.IsCasting && SpellManager.CanCast(116705)) ||
                 ((StyxWoW.Me.CurrentTarget.IsCasting && SpellManager.CanCast(115078)))))
            {
                Info("Can Interrupt...");
                return true;
            }
            return false;
        }

        public bool Interruptable()
        {
            return (StyxWoW.Me.CurrentTarget != null &&
                    StyxWoW.Me.CurrentTarget.IsCasting) &&
                   (LegSweep() || Paralysis() || QuakingPalm() || SpearHandStrike());
        }

        public bool IsCCd()
        {
            return (Helpers.Unit.HasAuraWithMechanic(StyxWoW.Me, WoWSpellMechanic.Asleep) ||
                    Helpers.Unit.HasAuraWithMechanic(StyxWoW.Me, WoWSpellMechanic.Horrified) ||
                    Helpers.Unit.HasAuraWithMechanic(StyxWoW.Me, WoWSpellMechanic.Fleeing) ||
                    Helpers.Unit.HasAuraWithMechanic(StyxWoW.Me, WoWSpellMechanic.Charmed) ||
                    Helpers.Unit.HasAuraWithMechanic(StyxWoW.Me, WoWSpellMechanic.Frozen) ||
                    Helpers.Unit.HasAuraWithMechanic(StyxWoW.Me, WoWSpellMechanic.Polymorphed) ||
                    Helpers.Unit.HasAuraWithMechanic(StyxWoW.Me, WoWSpellMechanic.Stunned) ||
                    Helpers.Unit.HasAuraWithMechanic(StyxWoW.Me, WoWSpellMechanic.Incapacitated));
        }

        public bool IsChiFull()
        {
            return (StyxWoW.Me.CurrentChi == StyxWoW.Me.MaxChi);
        }

        public bool OnCooldown(string spellName)
        {
            return SpellManager.Spells[spellName].Cooldown;
        }

        public bool PreCast()
        {
            if (!StyxWoW.Me.IsCasting &&
                !StyxWoW.Me.IsChanneling &&
                StyxWoW.Me.IsSafelyFacing(StyxWoW.Me.CurrentTarget) &&
                StyxWoW.Me.CurrentTarget.InLineOfSight &&
                StyxWoW.Me.CurrentTarget.InLineOfSpellSight &&
                !StyxWoW.Me.Fleeing &&
                !StyxWoW.Me.Stunned &&
                !StyxWoW.Me.Pacified)
                return true;
            return false;
        }

        public bool SpellInterruptable()
        {
            if (StyxWoW.Me.CurrentTarget.CastingSpellId == 118 || StyxWoW.Me.CurrentTarget.CastingSpellId == 421 ||
                StyxWoW.Me.CurrentTarget.CastingSpellId == 51514 || StyxWoW.Me.CurrentTarget.CastingSpellId == 115175)
            {
                Info("Spell Interruptable");

                return true;
            }
            return false;
        }

        #endregion
    }
}